package com.um.jdy.app.device.controller;

import com.um.jdy.app.device.entity.dto.DeviceStationListQuery;
import com.um.jdy.app.device.entity.dto.StationHomeQuery;
import com.um.jdy.app.device.entity.dto.StationListQuery;
import com.um.jdy.app.device.entity.dto.StationQuery;
import com.um.jdy.app.device.entity.vo.DeviceStationItemVO;
import com.um.jdy.app.device.entity.vo.StationDetailVO;
import com.um.jdy.app.device.entity.vo.StationItemVO;
import com.um.jdy.app.device.manager.StationManager;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.entity.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;


@Api(tags = "站场")
@RestController
@RequestMapping("/api/v1/device/station")
public class StationController {

    @Autowired
    StationManager stationManager;

    @ApiOperation("查询站场列表")
    @GetMapping("list")
    public Response<Page<StationItemVO>> getPage(StationListQuery query) {
        return Response.success(stationManager.getPage(query));
    }

    @ApiOperation("查询充电站详情")
    @GetMapping("detail")
    public Response<StationDetailVO> getStationDetail(StationQuery query){
        return Response.success(stationManager.getDetail(query));
    }

    @ApiOperation("查询某一种设备的站场列表")
    @GetMapping("{device_type}/list")
    public Response<Page<DeviceStationItemVO>> getDeviceStationPage(@ApiParam("设备类型：EB单车桩、EV汽车桩、EBox充电柜、PB充电宝") @PathVariable @NotBlank String device_type,
                                                                    DeviceStationListQuery query) {
        return Response.success(stationManager.getDeviceStationPage(device_type,query));
    }

    @ApiOperation("查询DIY首页")
    @GetMapping("home")
    public Response getStationHome(StationHomeQuery query) {
        return Response.success(stationManager.getStationHome(query));
    }

}
